using LiJ.Pay.WeiXin.SysTools;
using System.Collections.Generic;

namespace LiJ.Pay.WeiXin
{
	/// <summary>
	///  请求基类
	/// </summary>
	public class WxPayBaseReq
	{
		private readonly SortedDictionary<string, object> _dics = new SortedDictionary<string, object>();

		public WxPayBaseReq()
		{
			string value = SysUtil.GenerateNonceStr();
			this._dics["nonce_str"] = value;
		}

		/// <summary>
		///  设置当前实体中涉及加密的字段
		/// </summary>
		protected virtual void SetSignDics()
		{
		}

		/// <summary>
		///  设置加密字典条目
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		protected void SetDicItem(string key, object value)
		{
			if (!string.IsNullOrEmpty((value != null) ? value.ToString() : null))
			{
				this._dics[key] = value;
			}
		}

		public SortedDictionary<string, object> GetDics()
		{
			this.SetSignDics();
			return this._dics;
		}
	}
}
